package com.yiqi.lottery.feature.mine.view;

import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.widget.Button;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import com.suozhang.framework.framework.BaseActivity;
import com.suozhang.framework.utils.T;
import com.suozhang.framework.widget.PowerfulEditText;
import com.yiqi.lottery.R;
import com.yiqi.lottery.entity.bo.StationBo;
import com.yiqi.lottery.entity.bo.WithdrawBo;
import com.yiqi.lottery.feature.mine.contract.StationContract;
import com.yiqi.lottery.feature.mine.dependencies.station.DaggerStationComponent;
import com.yiqi.lottery.feature.mine.dependencies.station.StationPresenterModule;

import javax.inject.Inject;

public class WithdrawalAccountSettingActivity extends BaseActivity implements StationContract.View {


    @BindView(R.id.toolbar)
    Toolbar mToolbar;
    @BindView(R.id.btn_withdraw_wxs)
    Button mBtnWithdrawWxs;
    @Inject
    StationContract.Presenter mPresenter;
    @BindView(R.id.edt_user_withdraw_name)
    PowerfulEditText mEdtUserWithdrawName;
    @BindView(R.id.edt_user_withdraw_card)
    PowerfulEditText mEdtUserWithdrawCard;
    @BindView(R.id.edt_user_withdraw_mobile)
    PowerfulEditText mEdtUserWithdrawMobile;

    @Override
    protected int attachLayoutRes() {
        return R.layout.activity_withdrawal_account_setting;
    }

    @Override
    protected void initInjector() {
        DaggerStationComponent.builder().stationPresenterModule(new StationPresenterModule(this)).build().inject(this);
    }

    @Override
    protected void initView() {
        initToolBar(mToolbar, "银行账户设置", true, true);
    }

    @Override
    protected void initData() {
        mPresenter.getWithDraw();
    }


    @Override
    public void showStationInfoSuccess(StationBo msg) {

    }

    @Override
    public void showEditWithDrawSuccess(String msg) {
        showMsg("修改成功！");
        finish();
    }

    @Override
    public void showGetWithDrawSuccess(WithdrawBo msg) {
       if (msg!=null){
           mEdtUserWithdrawName.setText(TextUtils.isEmpty(msg.getWithdraw_name())?"":msg.getWithdraw_name());
           mEdtUserWithdrawCard.setText(TextUtils.isEmpty(msg.getWithdraw_account())?"":msg.getWithdraw_account());
           mEdtUserWithdrawMobile.setText(TextUtils.isEmpty(msg.getWithdraw_phone())?"":msg.getWithdraw_phone());
       }
    }


    @Override
    public void showError(String msg) {
        showErrorMsg(msg);
    }

    @OnClick(R.id.btn_withdraw_wxs)
    public void onViewClicked() {
        mPresenter.editWithDraw(mEdtUserWithdrawCard.getText().toString(), mEdtUserWithdrawName.getText().toString(), mEdtUserWithdrawMobile.getText().toString());
    }
}
